<template>
    <div>
        <div class="d-flex justify-content-between">
            <h5 class="mb-1" role="button" @click="copyText(`https://haijiao.com/post/details?pid=${item.topicId}`)">{{item.topicId}}</h5>
            <a href="#"
                    class="link-success"
                    @click="openUrlWithNewTab(`https://haijiao.com/post/details?pid=${item.topicId}`)"><i
                        class="bi bi-box-arrow-right"></i></a>
        </div>
        <p class="text-start">{{item.title}}</p>
        <div class="d-flex w-100 justify-content-between">
            <small role="button" @click="copyText(item.user.id)">{{item.user.nickname}}</small>
            <small>{{item.createTime}}</small>
        </div>
    </div>
</template>

<script setup lang="ts">
    import {openUrlWithNewTab} from "@/utils/haijiao"
    import type {ComponentInternalInstance} from "vue"
    const { proxy } = getCurrentInstance() as ComponentInternalInstance;
    const props = defineProps({
        item: {
            type: Object,
            default: {},
        },
    })
    const copyText = async (text: string | number) => {
        await navigator.clipboard.writeText(text as string)
        proxy?.$toast(`已复制: ${text}`)
    }
</script>
<style>
</style>